package com.jiyun.service.impl;

import com.jiyun.common.pojo.Mendian;
import com.jiyun.common.pojo.Mendianpingjia;
import com.jiyun.common.pojo.Mendianweizhi;
import com.jiyun.mapper.MendianMapper;
import com.jiyun.mapper.MendianPingjiaMapper;
import com.jiyun.mapper.MendianWeizhiMapper;
import com.jiyun.service.MendianService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class MendianServiceImpl implements MendianService {
    @Autowired
    MendianMapper mendianMapper;

    @Autowired
    MendianPingjiaMapper mendianPingjiaMapper;

    @Autowired
    MendianWeizhiMapper mendianWeizhiMapper;
    @Override
    public List<Mendian> findMendianAll(Mendian mendian) {
        List<Mendian> mendianAll = mendianMapper.findMendianAll(mendian);
        List<Mendianpingjia> pingfen = mendianPingjiaMapper.pingfen();
        List<Mendianweizhi> mendianweizhi = mendianWeizhiMapper.mendianweizhi();
        for (Mendian m : mendianAll) {
            m.setManDianpingjia(new Mendianpingjia());
            for (Mendianpingjia mendianpingjia : pingfen) {
                if (m.getMid()==mendianpingjia.getId()){
                    m.setManDianpingjia(mendianpingjia);
                }
            }
        }
        for (Mendian m : mendianAll) {
            m.setManDianweizhi(new Mendianweizhi());
            for (Mendianweizhi mendianweizhi1 : mendianweizhi) {
                if (m.getMid()==mendianweizhi1.getId()){
                    m.setManDianweizhi(mendianweizhi1);
                }
            }
        }
        return mendianAll;
    }

    @Override
    public List<Mendian> zonghe(Mendian mendian) {
        return mendianMapper.zonghe(mendian);
    }

    @Override
    public List<Mendian> juli(Mendian mendian) {
        return mendianMapper.juli(mendian);
    }

    @Override
    public List<Mendian> fetchBackendData() {
        return mendianMapper.fetchBackendData();
    }

    @Override
    public List<Mendian> validate(Integer cishu) {
        return mendianMapper.validate(cishu);
    }

    @Override
    public List<Mendian> fetchBackendData1() {
        return mendianMapper.fetchBackendData1();
    }

    @Override
    public List<Mendian> fetchBackendData2() {
        return mendianMapper.fetchBackendData2();
    }

    @Override
    public List<Mendian> fetchBackendData3() {
        return mendianMapper.fetchBackendData3();
    }

    @Override
    public List<Mendian> findMendianAllXq(Integer mid) {
        return mendianMapper.findMendianAllXq(mid);
    }


}
